package com.crazy.multids.config.druid;

import com.alibaba.druid.pool.DruidDataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * 此类的描述是：
 *
 * @author crazyhu@wezhuiyi.com
 * @date 2018-09-16 11:18
 **/
@Slf4j
//@Configuration
//@ConditionalOnClass(DruidDataSource.class)
public class DruidAutoConfiguration {

//    @Value("${spring.datasource.type}")
    private Class<? extends DataSource> dataSourceType;

//    @Bean
//    @ConfigurationProperties(prefix = "spring.datasource.master")
//    public DataSource masterDataSource() {
//        log.info("---------------master datasource init-------------");
//        return DataSourceBuilder.create().type(dataSourceType).build();
//    }
//
//    @Bean
//    @ConfigurationProperties(prefix = "spring.datasource.slave")
//    public DataSource slaveDataSource() {
//        log.info("---------------slave datasource init-------------");
//        return DataSourceBuilder.create().type(dataSourceType).build();
//    }
}
